"""
线索页面类
"""
from ..base_page import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

class CluePage(BasePage):
    #数据
    url="/crm/index.php?m=leads"
    #定位器
    clue_locator = (By.LINK_TEXT, "线索")
    add_clue_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(1) > div > a")
    # select_locator = (By.CSS_SELECTOR, "#source")
    bat_operate_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(1) > ul > li:nth-child(1) > div > a")
    del_locator = (By.CSS_SELECTOR, "#delete")
    see_clue_locator = (By.LINK_TEXT, "查看")
    # del_clue_locator = (By.LINK_TEXT, "删除")
    select_locator = (By.CSS_SELECTOR, "#source")
    selectclue_locator = (By.CSS_SELECTOR, "#form1 > table > tbody > tr > td:nth-child(1) > input")
    addclue_locator = (By.CSS_SELECTOR, "#remove")
    count_locator = (By.CSS_SELECTOR, "body > div.container > div.page-header > ul > li:nth-child(3) > a")
    switch_locator = (By.LINK_TEXT, "转换")
    tips_success_locator = (By.XPATH, "/html/body/div[5]/div[2]")
    tips_del_locator = (By.CSS_SELECTOR, "body > div.container > div.alert.alert-error")
    tips_del_clue_locator=(By.XPATH,"/html/body/div[5]/div[2]")
    tips_poll_success_locator=(By.XPATH,"/html/body/div[5]/div[2]")

    #方法
    def clue(self):
        self.click(self.clue_locator)
    def bat_clue(self):
        self.click(self.bat_operate_locator)
    def del_clue(self):
        self.click(self.del_locator)
    def add_clue(self):
        self.click(self.add_clue_locator)
    def see_clue(self):
        self.click(self.see_clue_locator)
    def bat_operate(self):
        self.click(self.bat_operate_locator)
    def selectclue(self):
        self.driver.execute_script("arguments[0].click();", self.find_element(self.selectclue_locator))
    def addclue(self):
        self.driver.execute_script("arguments[0].click();", self.find_element(self.addclue_locator))
    def count_clue(self):
        self.click(self.count_locator)
    def switch_clue(self):
        self.click(self.switch_locator)
    def tips_success(self):
        return self.find_element(self.tips_success_locator).text
    def tips_del(self):
        return self.find_element(self.tips_del_locator).text
    def tips_del_clue(self):
        return self.find_element(self.tips_del_clue_locator).text
    def tips_poll_success(self):
        return self.find_element(self.tips_poll_success_locator).text
    def tips_clue(self):
        return self.find_element(self.clue_locator).text